<%= render partial: "meeting_poll_actions" %>

<% if meeting.can_be_joined_by?(current_user) || meeting.on_different_platform? %>
  <section class="layout-aside__section layout-aside__buttons layout-aside__ctas-buttons" data-controller="sticky-buttons">
    <%= cell "decidim/meetings/join_meeting_button", meeting, show_remaining_slots: true, hide_modal: local_assigns[:hide_modal] %>
  </section>
<% end %>

<% if (meeting.closed? && meeting.closing_visible?) || (registration.present? && registration.meeting.component.settings.registration_code_enabled) || (meeting.services.any?) %>
<section class="layout-aside__section layout-aside__buttons">
  <% if meeting.closed? && meeting.closing_visible? %>
    <% if meeting.has_contributions? %>
      <%= render layout: "decidim/meetings/layouts/aside_block", locals: { emoji: "add-box-line" } do %>
        <h3 class="meeting__aside-block__title"><%= t("contributions", scope: "decidim.meetings.meetings.show") %></h3>
        <div class="meeting__aside-block__large"><%= meeting.contributions_count %></div>
      <% end %>
    <% end %>

    <% if meeting.has_attendees? %>
      <%= render layout: "decidim/meetings/layouts/aside_block", locals: { emoji: "group-line" } do %>
        <h3 class="meeting__aside-block__title"><%= t("attendees", scope: "decidim.meetings.meetings.show") %></h3>
        <div class="meeting__aside-block__large"><%= meeting.attendees_count %></div>
      <% end %>
    <% end %>

    <% if meeting.attending_organizations.present? %>
      <%= render layout: "decidim/meetings/layouts/aside_block", locals: { emoji: "community-line" } do %>
        <h3 class="meeting__aside-block__title"><%= t("organizations", scope: "decidim.meetings.meetings.show") %></h3>
        <ul class="meeting__aside-block__list">
          <% meeting.attending_organizations.split("\n").each do |organizations| %>
          <li><%= organizations %></li>
          <% end %>
          </ul>
        <% end %>
      <% end %>
    <% end %>

  <% if registration.present? %>
    <%= waitlist_status_block(registration) %>

    <% if registration.meeting.component.settings.registration_code_enabled && registration.registered? %>
      <%= render partial: "registration_code_modal" %>
      <%= render layout: "decidim/meetings/layouts/aside_block", locals: { emoji: "coupon-line" } do %>
        <a href="#" class="text-secondary underline font-semibold text-sm" data-dialog-open="RegistrationQRCodeDialog">
          <%= registration_code_help_text %>
        </a>
      <% end %>
    <% end %>
  <% end %>

  <% if meeting.services.any? %>
      <% meeting.services.each do |service| %>
        <%= render layout: "decidim/meetings/layouts/aside_block", locals: { emoji: "star-line" } do %>
          <h3 class="meeting__aside-block__title"><%= translated_attribute(service["title"]) %></h3>
          <div class="meeting__aside-block__text"><%= translated_attribute(service["description"]) %></div>
        <% end %>
      <% end %>
    <% end %>
    <%= cell "decidim/meetings/cancel_registration_meeting_button", meeting, hide_modal: local_assigns[:hide_modal] %>
  </section>
<% end %>
